global KaiA KaiC m kxy0 kxyA Khalf

%constants:
KaiA=1.3;                        % original concentration of KaiA
KaiC=3.4;                        % original concentration of KaiC
m=1;                             % parameter for adjustment
kxy0=[0 0 0 0.21;
      0 0 0.31 0;
      0 0 0 0.11;
      0 0 0 0];                  % matrix(4,4)
kxyA=[0 0.212923 0 0.0798462;
      0.173 0 -0.319385 0;
      0 0.505692 0 -0.133077;
      0.479077 0 0.0532308 0];   % matrix(4,4)
Khalf=0.43;                      % K_1/2 in equation

% 1,2,3,4 represent T,ST,S,U respectively

tspan=[0,100];
y0=[0.68;
    1.36;
    0.34;
    KaiC-0.68-1.36-0.34];        %T=0.68,D=1.36,S=0.34,U=1.02

[t,Y]=ode45('odefunction_Amax_paper',tspan,y0);

figure;plot(t,Y(:,1)*100/KaiC,'g',t,Y(:,2)*100/KaiC,'b',t,Y(:,3)*100/KaiC,'r',t,Y(:,4)*100/KaiC,'k','LineWidth',2);
legend('T','ST','S','U'); xlabel('time / h','FontSize',14); ylabel('%KaiC','FontSize',14); axis([0 100 0 100]);

figure;plot(t,Y(:,1)*100/KaiC,'g',t,Y(:,2)*100/KaiC,'b',t,Y(:,3)*100/KaiC,'r',t,(Y(:,1)+Y(:,2)+Y(:,3))*100/KaiC,'k','LineWidth',2);
legend('T','ST','S','total'); xlabel('time / h','FontSize',14); ylabel('%KaiC','FontSize',14); axis([0 100 0 100]);


A=max(0,KaiA-2*m*Y(:,3));
figure;plot(t,A,'LineWidth',2);
legend('A'); xlabel('time / h','FontSize',14);ylabel('concentration / \muM','FontSize',14);